#ifndef BASEFINDPACKET_H
#define BASEFINDPACKET_H

#include <QByteArray>
#include <QObject>
#include "portstatistics.h"

struct ProtocolPacket
{
    qint64   	timestamp;
    QByteArray 	buffer;

    void clear()
    {
        timestamp = 0;
        buffer.clear();
    }
};
Q_DECLARE_METATYPE(ProtocolPacket);

class BaseFindPacket : public QObject
{
    Q_OBJECT

public:
    BaseFindPacket(QObject *parent = nullptr);
    virtual ~BaseFindPacket();

    void setName(const QString &name);
    QString getName() const;

    void setStatistics(PortStatistics &statistics);

    virtual QList<ProtocolPacket> find(const QByteArray &data) = 0;
protected:
    QByteArray          m_rxBuffer; // 接收到的原始数据
    QByteArray 			m_rxPacket; // 合法包

    QString             m_name;

    PortStatistics      *m_statistics = nullptr;
};
Q_DECLARE_METATYPE(QList<ProtocolPacket>);


#endif // BASEFINDPACKET_H
